<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        body {
            background: url(images/pexels-julius-silver-753626.jpg) no-repeat center top;
            background-size: 100%;
        }
        li {
            list-style: none;
        }
        .huanfu {
            overflow: hidden;
            margin: 100px auto;
            background-color: #fff;
            width: 410px;
            padding-top: 3px;
        }
        .huanfu li {
            float: left;
            margin: 0 1px;
            cursor: pointer;
        }
        .huanfu img {
            width: 100px;
        }
    </style>
</head>
<body>
    <div class="huanfu">
        <ul>
            <li><img src="images/pexels-julius-silver-753626.jpg" alt=""></li>
            <li><img src="images/pexels-pixabay-371589.jpg" alt=""></li>
            <li><img src="images/pexels-s-migaj-747964.jpg" alt=""></li>
            <li><img src="images/pexels-tobi-620337.jpg" alt=""></li>
        </ul>
    </div>
    <script>
        var body = document.body;
        var img = document.querySelector('.huanfu').querySelectorAll('img')
        console.log(img);
        for (var i=0;i<img.length;i++) {
            img[i].onclick = function() {
                body.style.backgroundImage = 'url(' + this.src + ')'
            }
        }
    </script>
</body>
</html>